home *** CD-ROM | disk | FTP | other *** search
/ boe.pres.k12.wv.us / boe.pres.k12.wv.us.zip / boe.pres.k12.wv.us / Utilities / Xerox Workcentre 5335 / Windows Scan / 64-bit_x64 / Russian / cpsimage.cab / data / xps / fiji2xps.elf next >
Text File  |  2009-04-23  |  2KB  |  81 lines

  1. /*
  2. ** What this script is for:
  3. ** Write single page XPS output format by reading input image, segments
  4. ** using fiji nlayer, added thumbnail, and does OCR if option asked for.
  5. ** NOTE: this script assumes that the input image is a single image raster
  6. **       format supported by XIPS. For example, jpeg, tiff, png, gif, etc.
  7. */
  8.  
  9. // The TimeCheck() function reports the time to this point in the execution
  10. print "time to start interpreter = " + TimeCheck() + "secs";
  11.  
  12. // Load scripted support procedures
  13. //#load "xipProcs/printLayer.proc";
  14. #load "xps/xmetWriteXPS.proc";        // XPS support procs
  15.  
  16. // Import FIJI definitions
  17. #import "fiji2xip.ucm";
  18. #import "fwx2xip.ucm";
  19.  
  20. // Import XEngine image processing definitions
  21. LoadClasses ( filename: "xeng");
  22.  
  23. #load "xipProcs/getOcrPage.proc";
  24.  
  25. ///////////////// Main Program ////////////////////////////////////////
  26.  
  27. // Importable value for variable "image"
  28. IMPORT STRING image;
  29. IMPORT STRING language = "English";
  30. IMPORT INTEGER ocr = 1;     // Default is on
  31. STRING ocrformat = "XDOC";
  32. STRING ocrxdoc, ocrxml;
  33.  
  34. // Test for proper parameters
  35. if ( !image) {
  36.   print "Usage: \"xipe fiji2xps.elf -im image:s filename language:s language ocr:i 0|1\" ";
  37.   end;
  38.   }
  39.  
  40. // Set output filename
  41. STRING outxps = image.name() + ".xps";
  42.  
  43. // Read and segment image
  44. XIPIMAGE img = readimage (filename: image );
  45.  
  46. // Get thumbnail
  47. XIPIMAGE thumb = img.thumbnail();
  48.  
  49. // See fijiSeg method for documentation on arguments
  50. print "FIJI Segmentation ...";
  51. XIPIMAGE ims = img.fijiSeg (cfgfile: "$XIPTOP/data/fiji/fijiNl.cfg");
  52. print "Segmented image has " + ims.nlayers + " layers";
  53.  
  54. // Add thumbnail to segmented image
  55. ims.addLayer(image:thumb, ltype: XIP_Thumbnail);
  56.  
  57.  
  58. if ( ocr ) {
  59.    print "OCR ...";
  60.    XIPIMAGE ocrimg = getOcrPage (input:ims);
  61.    ocrxdoc = ocrimg.fwxOCR (texttype: ocrformat, language: language);
  62.    XIPIMAGE ocrxip  = XDOCtoXIPXML(xdoc: ocrxdoc);
  63.    ims.addLayer(image:ocrxip, ltype: XIP_Text);
  64.    }
  65.  
  66. print "WriteXPSOpen";
  67. WriteXPSOpen(filename: outxps);
  68.  
  69. print "WriteXPSPage";
  70. /*  8.5x 11 page DOUBLE page_x = 215.9; DOUBLE page_y = 279.4; */
  71. DOUBLE page_x = 0;   //Auto mode
  72. DOUBLE page_y = 0;
  73. WriteXPSPage(filename: outxps, img: ims, pgNum: 1, page_x: page_x, page_y: page_y);
  74.  
  75. print "WriteXPSClose";
  76. WriteXPSClose(filename: outxps);
  77.  
  78. // How long has this taken
  79. print TimeCheck();
  80. print "output xps file = " + outxps;
  81.